import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zengfh
 * @version 1.0
 * date 2018/04/27 14:04
 */
public class TestUnsafeThread{
    
    
    static CountDownLatch countDownLatch = new CountDownLatch(1000);
    
    public static void main(String[] args) {
    
        ExecutorService executorService = Executors.newFixedThreadPool(1000);
        
/*        for (int i = 0;i < 1000;i++){
            executorService.execute(new UnsafeThread());
        }*/
        UnsafeThread unsafeThread = new UnsafeThread();
        Thread thread = new Thread(unsafeThread);
        thread.start();
        thread.start();
    
    }
    
    static class UnsafeThread implements Runnable{
        static int allval = 49;
    
    
        @Override
        public void run() {
        
            allval++;
        
        
            try {
                //Thread.sleep(1000);
                System.out.println("allval 的值为：" + allval);
                countDownLatch.await();
                
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            } finally {
                countDownLatch.countDown();
            }
        }
    
    }
}
